#ifndef _GP_TASK_H
#define _GP_TASK_H

#include "common.h"
#include "gp_layout_map.h"
#include "resource_manage.h"
#include <pthread.h>

typedef enum
{
    TASK_ACT_DP8_LOAD_TIP,
    TASK_ACT_DP8_DROP_TIP,
    TASK_ACT_DP8_SUCK,
    TASK_ACT_DP8_SPIT,
    TASK_ACT_TECAN_DROPTIP,
    TASK_ACT_TECAN_SUCK,
    TASK_ACT_TECAN_SPIT,
    TASK_ACT_TECAN_LOADTIP,
    TASK_ACT_DJ_PURIFY_CLEAN,
    TASK_ACT_DJ_PURIFY_SUCK,
    TASK_ACT_DJ_PURIFY_SPIT,
    TASK_ACT_DJ_QPCR_CLEAN,
    TASK_ACT_DJ_QPCR_SUCK,
    TASK_ACT_DJ_QPCR_SPIT,
}en_task_act_type;


typedef struct suck_spit_param
{
    int prePos;
    int quantity;
    int postPos;   
}suck_spit_param;

typedef struct _act_param
{
    int actType;
    union 
    {
        move_param * moveParamHead;
        djLiquidCtl djLiquidCtlParam;
        suck_spit_param suckSpitParam;
        tecan_tip_param tecanTipParam;
        tecan_init_param tecanInitParam;
    }un_param;
       
}act_param;

typedef enum
{
    STAGE_NOT_START,
    STAGE_ADD_BREAKDOWN,
    STAGE_ADD_PROTAINASE,
    STAGE_ADD_HELPDOWN,
    STAGE_ADD_MAGNET,
    STAGE_ADD_SAMPLE,
    STAGE_ADD_INTERNAL_REFERENCE,
    STAGE_SPLITTING,
    STAGE_DROP_SPLIT_WASTE,
    STAGE_ADD_WASHOFF,
    STAGE_WASHOFF,
    STAGE_DROP_WASHOFF_WASTE,
    STAGE_ADD_CLEAN1,
    STAGE_CLEAN1,
    STAGE_DROP_CLEAN1_WASTE,
    STAGE_ADD_CLEAN2,
    STAGE_CLEAN2,
    STAGE_DROP_CLEAN2_WASTE,
    MAX_STAGE_NUM,    
}en_purify_stage;

//one task include actions in one stage.
class CGpTask
{
public:
    CGpTask(int stageIn,int tube8Id);
    int start(void );
    int stop(void);
    ~CGpTask();

    int getRemainVolume(location_layout * plocIn, int isTube8);
    void writeRemainVolume(location_layout * plocIn, int isTube8, int volumeToSet);
    
private:
    char * paramMem;

    int m_nodeNum;
    int m_currNodeIndex;
    int m_moduleId;
    void set_add_split_param(void);
    void set_action_param(void);
    

    int m_tube8Id;

    CReagent * m_pstReagent;

    CTube_8Holes * m_pstTube8Manage;

    pthread_t m_threadHandle;

	int m_stageId;
    
};

#define MAX_TASK_PARAM_LEN 1024

int read_liquid_trans_param(const char * fileNameIn, const char* pathIn, void * paramOut,int *numParam);

typedef void (*moduleActFunc_internal)(void* paramIn, CGpTask * pTask);


typedef enum
{
    SUCK1_SPIT1,
    SUCK1_SPITM,
    SUCKM_SPITM,
}en_liuquid_trans_type;

void * threadFuncTask(void * paramIn);

int dj_p_task_act_func(void * paramIn, CGpTask * pTask);

#endif